<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'zijin.jsp' starting page</title>
  <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/hplus/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/hplus/css/plugins/bootstrap-table/bootstrap-table.min.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/hplus/css/plugins/sweetalert/sweetalert.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/bootstrap.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/plugins/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/hplus/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

<link rel="shortcut icon" href="${pageContext.request.contextPath}/hplus/favicon.ico">
<link href="${pageContext.request.contextPath}/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
<link href="${pageContext.request.contextPath}/hplus/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
<link href="${pageContext.request.contextPath}/hplus/css/animate.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">
<script>
		$(function(){
			$("#xiu").click(function(){
				var jie=$("#sum").text();
				$("#jie").val(jie);
				
			});
			bian();
			bianyi();
			
			
		})
		window.onload = function(){
				liangwei();
				var tthe = $("#tthe").text();
				console.log(tthe=="0.0")
				
				console.log(typeof tthe)
				
				if(tthe =="0.0" || tthe==null || tthe==undefined){
					
				}else{
					$("#gai").remove();
				}
				
				
			}
		function xiu(){
		
				var jie=$("#jie").val();
				var zid=$("#zid").val();
				var id=$("#id").val();
				$("#myModal").modal("hide");
				$.post("zijin.do?mm=2",{"jie":jie,"id":id,"zid":zid},function(data){
					var r=eval("("+data+")");
					$("#sum").text(r);
					geng();
					bian();
					bianyi();
				})
				
			
		}
		function geng(){
			
			var chhhh=parseFloat($("#chhh").text());
			var sss=parseFloat($("#sum").text());
			var jieguo=chhhh/sss*100;
			var a=jieguo.toPrecision(3)
			$("#bai").text(a);
		}
		function bianyi(){
			var sb=parseFloat($("#bai").text());
			var zi=$("#zid").val();
			
			var money="";
			if(sb>=100){
				money="有";
				
				$.post("zijin.do?mm=4",{"money":money,"zid":zi},function(data){
					var r=eval("("+data+")");
					$("#flag").val(r);
				})
			}else if(sb<100){
				money="无";
				
				$.post("zijin.do?mm=4",{"money":money,"zid":zi},function(data){
					var r=eval("("+data+")");
					$("#flag").val(r);
				})
			}
		}
		function liangwei(){
			
			/* var yi=parseFloat($(".yi").text());
			var er=parseFloat($(".er").text());
			var san=parseFloat($(".san").text());
			var si=parseFloat($(".si").text());
			var wu=parseFloat($(".wu").text());
			
			
			$(".yi").text(yi.toPrecision(4));
			$(".er").text(er.toPrecision(4));
			$(".san").text(san.toPrecision(4));
			$(".si").text(si.toPrecision(4));
			$(".wu").text(wu.toPrecision(4)); */
		}
		function bian(){
			
			
			
			
			var sb=parseFloat($("#bai").text());
			if(sb>=60){
				$("#bai").css("color","red");
			}else{
				$("#bai").css("color","#000");
			}
		}
		function tianhe(){
			var zid=$("#zid").val();
			var the=$("#the").val();
			var tjie=$("#tjie").val();
			$("#Moda").modal("hide");
			$.post("zijin.do?mm=5",{"the":the,"zid":zid,"tjie":tjie},function(data){
					var r=eval("("+data+")");
					$("#tthe").text(r.camount);
					$("#sum").text(r.sum);
					$("#gai").remove();
				})
		}
		var iddd;
		var zzzz;
		var jia;
		function del(obj,id){
			zzzz=$(obj).parent().prev().text();
			jia=$(obj).parent().parent();
			iddd=id;
		}
		function dd(){
			var cid=$("#id").val();
			$("#d").modal("hide");
			
			
			
				$.post("zijin.do?mm=6",{"id":iddd,"cid":cid},function(data){
					if(data==1){
						$(jia).remove();
						
						zzzz=parseFloat(zzzz);
						var ss=parseFloat($("#chhh").text());
						var sss=ss-zzzz;
						
						
						$("#chhh").text(sss.toPrecision(3));
						
						var bai=parseFloat($("#sum").text());
						var bb=sss/bai*100;
						$("#bai").text(bb.toPrecision(3));
						
						
						bian();
						bianyi();
					}
					
					
				}) 
			
			
			
		}
		function add(){
			var  f=$("#f").val();
			var z=$("#z").val();
			var s=$("#s").val();
			var q=$("#q").val();
			var cid=$("#id").val();
			$("#Modal").modal("hide");
				$.post("zijin.do?mm=3",{"f":f,"z":z,"s":s,"q":q,"cid":cid},function(data){
					var r=eval("("+data+")");
					var l="<tr class='dle'>"+
								"<td>"+r.time+"</td>"+
								"<td class='yi'>"+r.materials.toPrecision(3)+"</td>"+
								"<td class='er'>"+r.mate.toPrecision(3)+"</td>"+
			    				"<td class='san'>"+r.fee.toPrecision(3)+"</td>"+
			    				"<td class='si'>"+r.other.toPrecision(3)+"</td>"+
			    				"<td class='wu'>"+r.zong.toPrecision(3)+"</td>"+
			    				"<td><a data-toggle='modal' data-target='#d' data-whatever='@getbootstrap' onclick='del(this,"+r.id+")'>删除</a></td>"+
			    				"</tr>";
						$("#tianjia").append(l);
						var ss=parseFloat($("#chhh").text());
						var sss=ss+r.zong;
						$("#chhh").text(sss);
						
						var bai=parseFloat($("#sum").text());
						var bb=sss/bai*100;
						
						
						$("#bai").text(bb.toPrecision(3));
						$("#f").val(0);
						$("#z").val(0);
						$("#s").val(0);
						$("#q").val(0);
						bian();
						bianyi();
				})
				
				
		}
		
</script>
<style type="text/css">
	td{
		border:1px solid #e7eaec;
	}
</style>
  </head>
  	<input type="hidden" id="id" value="${c.id }">
  	<input type="hidden" id="zid" value="${zid }">
  	<input type="hidden" id="flag" value="">
   <div id="btndiv">
   		<button type="button" id="gai" class="btn" data-toggle="modal"
			data-target="#Moda">添加合同金额和已结金额</button>
		<button type="button" id="xiu" class="btn" data-toggle="modal"
			data-target="#myModal">修改已结金额</button>
			<button type="button" id="add" class="btn" data-toggle="modal"
			data-target="#Modal">添加费用状况</button>
			<input type="button" class="btn"  onClick="javascript:history.go(-1);location.replace(document.referrer);"  value="返回" />
			
	</div>
	
  <body>
    <table class="table table-hover" style="text-align:center; margin-top:20px;margin-bottom:0px;">
    	<tr>
    		<td colspan="2">资金状况</td>
    		<td>已花已结金额的</td>
    		
    	</tr>
    	<tr>
    		<td>合同金额</td>
    		<td>已结金额</td>
    		<td><span id="bai">${c.bai}</span>%</td>
    	</tr>
    	<tr>
    		<td id="tthe">${c.camount}</td>
    		<td id="sum">${c.sum}</td>
    		<td>共计花费</td>
    	</tr>
    </table>
    <table id="tianjia" class="table table-hover" style="text-align:center;">
    	<tr>
    		<td colspan="5">费用状况</td>
    		<td style="background-color:red;color:#000" id="chhh">${c.chu}</td>
    	</tr>
    	<tr id="xia">
    		<td>花费时间</td>
    		<td>辅材</td>
    		<td>主材</td>
    		<td>施工费</td>
    		<td>其他费用</td>
    		<td>合计</td>
    		<td>操作</td>
    	</tr>
    	<c:forEach items="${list}" var="l">
    		<tr class="dle">
	    		<td>${l.time }</td>
	    		<td class="yi">${l.materials }</td>
	    		<td class="er">${l.mate }</td>
	    		<td class="san">${l.fee }</td>
	    		<td class="si">${l.other }</td>
	    		<td class="wu">${l.zong }</td>
	    		<td><a data-toggle="modal" data-target="#d" data-whatever="@getbootstrap" onclick="del(this,${l.id})">删除</a></td>
	    	</tr>
    	</c:forEach>
    </table>
    <div class="modal fade" id="myModal">
	  <div class="modal-dialog" role="document">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myModalLabel">修改已结金额</h4>
	      </div>
	      <div class="modal-body">
	        	 <form>
				  <div class="form-group">
				    <label for="name">已结金额</label>
				   <input type="text" class="form-control" id="jie" > 
				  </div>
				</form>
	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
	        <button onclick="xiu()" type="button" class="btn btn-primary">提交</button>
	      </div>
	    </div>
	  </div>
	</div>
	
	
	<div class="modal fade" id="d">
	  <div class="modal-dialog">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myModalLabel">提示信息！</h4>
	      </div>
	      <div class="modal-body">
	        	确认要删除吗？
	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
	        <button onclick="dd()" type="button" class="btn btn-primary">确定</button>
	      </div>
	    </div>
	  </div>
	</div>
	
	
	 <div class="modal fade" id="Moda">
	  <div class="modal-dialog" role="document">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myModalLabel">修改已结金额</h4>
	      </div>
	      <div class="modal-body">
	        	 <form>
	        	  <div class="form-group">
				    <label for="name">合同金额</label>
				   <input type="text" class="form-control" id="the" > 
				  </div>
				  <div class="form-group">
				    <label for="name">已结金额</label>
				   <input type="text" class="form-control" id="tjie" > 
				  </div>
				</form>
	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
	        <button onclick="tianhe()" type="button" class="btn btn-primary">提交</button>
	      </div>
	    </div>
	  </div>
	</div>
	
	
	
	
	 <div class="modal fade" id="Modal">
	  <div class="modal-dialog" role="document">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myModalLabel">添加费用状况</h4>
	      </div>
	      <div class="modal-body">
	        	 <form>
				  <div class="form-group">
				    <label for="f">辅材</label>
				   <input type="text" class="form-control" id="f" value="0" > 
				  </div>
				   <div class="form-group">
				    <label for="z">主材</label>
				   <input type="text" class="form-control" id="z" value="0"> 
				  </div>
				   <div class="form-group">
				    <label for="s">施工费</label>
				   <input type="text" class="form-control" id="s" value="0"> 
				  </div>
				   <div class="form-group">
				    <label for="q">其他费用</label>
				   <input type="text" class="form-control" id="q" value="0"> 
				  </div>
				</form>
	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
	        <button onclick="add()" type="button" class="btn btn-primary">提交</button>
	      </div>
	    </div>
	  </div>
	</div>
  </body>
</html>
